<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>申请开店</title>
		<script src="__INDEX__/js/mui.min.js"></script>
		<link href="__INDEX__/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="__INDEX__/css/iconfont.css" />
		<link rel="stylesheet" href="__INDEX__/css/style.css" />
		<link rel="stylesheet" href="__INDEX__/css/mall.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" href="JavaScript:history.go(-1)"></a>
			<h1 class="mui-title">申请开店</h1>
		</header>
		<div class="mui-content ">
			<form id='my_form' class="mui-input-group gerenzl_group layui-form update_form">
				<div class="gerenzl_nr">
					<div class="gerenzl_top img-click">
						<div class="actions" style="text-align: center; padding-top: 20px;">
							<button id="test1" type="button" class="file-btn">
				   		 		<div class="layui-upload">
								  <div class="layui-upload-list" style="margin: unset;">
								    <img class="layui-upload-img" id="logo" src="">
								    <input type="hidden" name='logo' value="" id='thumb' />
								    <p id="demoText"></p>
								  </div>
								</div>  
							</button>
						    <div style="font-size: 1rem; line-height: 1.5rem; margin: 10px 0px;">商户LOGO</div>
						</div>
					</div>
					<div style="height:5px;background-color: #EFEFF4;"></div>
					<div class="mui-input-row ">
						<label><em>*</em>商户名称</label>
						<input type="text" name="agent_name" lay-verify="required" class="layui-input" placeholder="请输入商户名称">
					</div>
					<div class="mui-input-row">
						<label><em>*</em>商户地址</label>
						<input type="text" name="address" lay-verify="required" class="layui-input" placeholder="请输入商户地址">
					</div>
					<div class="layui-form-item" style="border-bottom: 1px solid #EEEEEE;">
					    <label class="layui-form-label"><em>*</em>类型</label>
					    <div class="layui-input-block">
					      <select  name="store_property" lay-verify="required">
					        <option value="1">个人</option>
					        <option value="2">企业</option>
					        <option value="3">个体户</option>
					      </select>
					    </div>
					</div>
					<div class="gerzl_btn" style="position: relative; text-align: center; line-height: 80px; height: 80px;">
			        	<button type="button" lay-submit lay-filter="submit_form" class="layui-btn" >保存</button>
			        </div>
				</div>
			</form>

		</div>

	</body>
</html>
{include file="public/footer" /}
<script>
	//提交表单
	function set_content(){
  		 $.ajax({
             	type:"post",
                url:"{:url('index/member/shenqing')}",
                data: $('#my_form').serialize(),//表单数据
                success:function(data){
                    layer.msg(data.msg, {
						  icon: 1,
						  time: 1500 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
							location.href = "{:url('index/member/index')}";
						});
                }
        });
  		
  	}
</script>
<script>
//图片上传
	layui.use(['form','upload'], function(){
  		var $ = layui.jquery,upload = layui.upload,form = layui.form;
  		
  		//监听表单提交
  		form.on('submit(submit_form)', function(data){
  			set_content();
		  return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
		});
  		
  		//监听select选择
  		form.on('select(agency_list)', function(data){
  			var agency_id = parseInt(data.value);
			var sel_html = "<option value=''>请选择市代</option>";
			for(var i=0;i<city_list.length;i++){
				if( agency_id == city_list[i]['agency_id']){
					sel_html += "<option value='"+city_list[i]['id']+"'>"+city_list[i]['city']+"</option>";
				}
			}
			$('#city_list').empty();
			$('#city_list').append(sel_html);
		});    
  		
  		
  		
  		
  		
  		
  		//普通图片上传
		var uploadInst = upload.render({
			elem: '#test1'
		    ,auto: false //选择文件后不自动上传
		    ,choose: function(obj){
			    //将每次选择的文件追加到文件队列
			    var files = obj.pushFile();
			    
			    //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
			    obj.preview(function(index, file, result){
			    	$('#logo').attr('src', result); //图片链接（base64）
			    	var sendData = result.substring(result.indexOf(";base64,")+8);
			    	$.post("{:url('index/member/upload')}",{value:sendData},function(data){ 
	                            if(data.code == '200'){  
	                            	$('#thumb').val(data.url);
	                            }else{  
	                                layer.msg(data.msg);
	                            }  
                    		});
			    });
			}
		    ,url: "{:url('index/member/upload')}"
		    ,accept:'images'
		});
	})
</script>
 <!----      图片上传 end       ---->